<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ page import="com.are.odisea.*"%>
<%@include file="validausuario.jsp"%>
<%
String rolp="VNOT";
if(!RolesPag.tienePermiso(rolp,(String)session.getAttribute("id_usuario"))){
	response.sendRedirect("index.jsp");	
}
db conexion = new db();
ArrayList<Categoria> lista = new ArrayList<Categoria>();
Categorias cat = new Categorias(conexion);
String categoria="";
String criterio="";
if (request.getParameter("criterio")!=null){
	criterio=(String) request.getParameter("criterio");
}
if (request.getParameter("categoria") != null) {
	categoria = (String)request.getParameter("categoria");
	int id = Integer.parseInt(categoria);
	lista = cat.GetCatHijas(id);  // obtener lista de categorias de documentos;
}else {
	lista = cat.GetCatHijas(5);  // obtener lista de categorias de documentos;
}
int fila =0;
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Odisea - Bandeja de Noticias</title>
	<link rel="stylesheet" href="themes/redmond/jquery.ui.all.css">
	<LINK REL="stylesheet" TYPE="text/css" HREF="main.css">
	<link rel="stylesheet" href="themes/redmond/demo_page.css">
	<link rel="stylesheet" href="themes/redmond/demo_table.css">
	<script src="ui/jquery-1.8.0.js" language="JavaScript"></script>
	<script src="ui/jquery.ui.core.js" language="JavaScript"></script>
	<script src="ui/jquery.ui.widget.js" language="JavaScript"></script>
	<script src="ui/jquery.ui.tabs.js" language="JavaScript"></script>
	<script src="ui/jquery.ui.button.js"></script>
	<script src="ui/jquery.effects.core.js"></script>
	<script src="ui/jquery.effects.slide.js"></script>
	<script src="ui/jquery.ui.datepicker.js"></script>
	<script src="ui/jquery.effects.explode.js"></script>
	<script src="ui/jquery.effects.fold.js"></script>
	<script src="ui/jquery.effects.slide.js"></script>
	<script src="ui/jquery.ui.draggable.js"></script>
	<script src="ui/jquery.ui.position.js"></script>
	<script src="ui/jquery.ui.resizable.js"></script>
	<script src="ui/jquery.ui.dialog.js"></script>
	<script src="ui/jquery.effects.core.js"></script>
	<script src="ui/jquery.ui.widget.js"></script>
	<script src="ui/jquery.ui.mouse.js"></script>
	<script src="ui/jquery.bgiframe-2.1.2.js"></script>
	<script src="js/jquery.js" type="text/javascript"></script>
	<script src="js/jquery.tablePagination.0.5.js"></script>
	<script type="text/javascript">
	
	$(document).ready(function() {
		$('#Grid').tablePagination("10");
	} );
	function listTer() {
		$("#Noticias").load("SrvNoticias?operacion=listTer&categoria=<%=categoria%>&filtro=<%=criterio%>",function() {
			$('#Grid').tablePagination("10");
		});
	}
	function listUlt() {
		$("#Ultimas").load("SrvNoticias?operacion=listTerUlt");
	}
	</script>
</head>
<body onload="listTer(); listUlt()">
<%@include file="header.jsp"%>
<div class="contencenter demo">
	<div style="width:60%;">
	<H2><img src="images/Noticias.png" />Noticias</H2>
	<form action="" name="form1">
		Busqueda: <input type="text" size=40 name="criterio" id="criterio"/> Categoria: 
		<select name="categoria" id="categoria">
			<option value="-1">Todas</option>
			<% if (lista.size() > 0) { %>
			<% for (Categoria categ: lista) { %>
				<option value="<%= categ.getId() %>"><%= categ.getDescripcion() %></option>
			<% } %>
			<% } %>
		</select>
		<input type="submit" value="Buscar" name="cmd_buscar" id="cmd_buscar">
	</form>
	<% if (lista.size() > 0) { %>
	<h2>Categorias</h2>
	<table>
		<tr>
			<th>Categorias</th>
		</tr>
		<% for (Categoria categ: lista) { %>
		<tr <%= (fila%2==0)?"class='odd'":"" %>>	
			<td><a href="VerNoticias.jsp?categoria=<%= categ.getId()  %>"><img src="images/Folder.png" /></a><%= categ.getDescripcion() %></td>
		</tr>
		<% fila++; %>
		<% } %>
		<tr <%= (fila%2==0)?"class='odd'":"" %>>	
			<td><a href="javascript:history.back(1)" title="Volver"><img src="images/Folder.png" /></a>...</td>
		</tr>
	</table>		
	<% }else{%>
	<table>
	<tr <%= (fila%2==0)?"class='odd'":"" %>>	
			<td><a href="javascript:history.back(1)" title="Volver"><img src="images/Folder.png" /></a>...</td>
		</tr>
	</table>
	<%} %>
	</div>
	<div id="Noticias">
	
	</div>
	<div id="Ultimas">
	
	</div>
</div>
<%@include file="foot.jsp"%>
</body>
</html>
<%
	if (conexion != null) {
		conexion.Close();
	}
%>